package cn.ydxiaoshuai.tools.lanuch;

import cn.ydxiaoshuai.tools.conts.JobConts;
import cn.ydxiaoshuai.tools.factory.AipMultiple;
import cn.ydxiaoshuai.tools.factory.BDFactory;
import cn.ydxiaoshuai.tools.task.TaskUtil;
import cn.ydxiaoshuai.tools.util.RedisUtil;
import com.baidu.aip.face.AipFace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @author 小帅丶
 * @className StartMethodRunner
 * @Description 初始加载方法
 * @Date 2020/4/10-15:05
 **/
@Component
@Slf4j
public class AStartMethodRunner implements ApplicationRunner {
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private TaskUtil taskUtil;
    @Override
    public void run(ApplicationArguments args) {
        log.info("初始化微信小程序AccessToken");
        taskUtil.getAccessToken();
        log.info("初始相关坐标参数");
        redisUtil.set(JobConts.AVATAR_KEY, "554,530");
        redisUtil.set(JobConts.MERGE_KEY, "500,720");
        redisUtil.set(JobConts.QRCODE_KEY, "57,1828");
        redisUtil.set(JobConts.NICKNAME_KEY, "500,1173");
        redisUtil.set(JobConts.JOBNUM_KEY, "500,1240");
        log.info("初始缩放参数，默认不缩放");
        redisUtil.set(JobConts.ZOOM_KEY,JobConts.ZOOM_VALUE_0);
        log.info("微信图片违规检测，默认不开启");
        redisUtil.set(JobConts.CHECK_IMG_KEY,JobConts.ZOOM_VALUE_0);
        log.info("单例加载百度SDK");
        AipMultiple aipMultiple = BDFactory.getAipMultiple();
        aipMultiple.detect("http://aip.bdstatic.com/portal-pc-node/dist/1586441726384/images/technology/face/detect/demo-card-2.jpg", "URL", null);
    }
}
